﻿@using PlatformNetCore.Entity
@{
    ViewBag.Title = "编辑单页";
}
@model SinglePage
<style>
    html {
        background-color: #fff;
    }

    .layui-card {
        box-shadow: none;
    }
</style>
<!-- 配置文件 -->
<script src="~/lib/ckeditor/ckeditor.js"></script>

<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="@Url.Action("SinglePageEdit","Basis",new { area = "Admin"})" lay-filter="useredit-form">
            <div class="layui-form-item">
                <label class="layui-form-label">标题*</label>
                <div class="layui-input-block">
                    <input type="hidden" name="ID" lay-verify="required" autocomplete="on" class="layui-input">
                    <input type="text" name="Title" lay-verify="required" placeholder="标题" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">代码</label>
                <div class="layui-input-block">
                    <input type="text" name="SingPageCode" placeholder="代码（必须唯一）" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">单页类型*</label>
                <div class="layui-input-block">
                    <select name="SingPageType" lay-filter="SingPageType" lay-verify="required">
                        @foreach (var item in (IEnumerable<SelectListItem>)ViewBag.SinglePageTypeDLL)
                        {
                            <option value="@item.Value">@item.Text</option>
                        }
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序号</label>
                <div class="layui-input-block">
                    <input type="text" name="SortNo" lay-verify="required" placeholder="排序号" autocomplete="on" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">内容*</label>
                <div class="layui-input-block">
                    <!-- 加载编辑器的容器 -->
                    <textarea id="Content" name="Content"></textarea>
                </div>
            </div>
            <div id="useredit-submit" lay-submit lay-filter="useredit-submit"></div>
        </form>
    </div>
</div>
<script>
    CKEDITOR.replace('Content');

    //处理CKEDITOR的值
    function CKUpdate() {
        for (instance in CKEDITOR.instances)
            CKEDITOR.instances[instance].updateElement();
    }

    layui.use(['form'], function () {
        var $ = layui.$, form = layui.form;

        form.render(null, 'useredit-form');

        //从父层获取值，json是父层的全局js变量。eval是将该string类型的json串变为标准的json串
        var editObj = parent.editData;
        //表单初始赋值
        form.val('useredit-form', {
            "ID": editObj.ID
            , "Title": editObj.Title
            , "SingPageCode": editObj.SingPageCode
            , "SingPageType": editObj.SingPageType
            , "SortNo": editObj.SortNo
            , "Content": editObj.Content
        });
    });
</script>
